NAME
lc_geterrno - Retrieve a numeric error code.SYNOPSIS
#include <libconfig.h>lc_err_t lc_geterrno(void);
DESCRIPTION
The lc_geterrno(3) function returns the last numeric error code set as an lc_err_t which is an enumerated type and can be cast to any integer type.The lc_err_t type specifies the following defined values:
- LC_ERR_NONE
- No error was found. Success.
- LC_ERR_INVCMD
- A command was specified for which there was no handler.
- LC_ERR_INVSECTION
- A section was specified for which there was no handler.
- LC_ERR_INVDATA
- A value that does not make sense was specified, such as a non-existant type to the lc_process_file(3) function.
- LC_ERR_BADFORMAT
- An invalid format was detected, such as no argument where on was expected, or a value passed to a boolean-specified variable whose value was not one of: enable, true, yes, on, y, 1, disable, false, off, no, n, 0.
- LC_ERR_CANTOPEN
- Unable to open a specified file.
- LC_ERR_CALLBACK
- A callback function returned an error (LC_CBRET_ERROR).
- LC_ERR_ENOMEM
-
Memory could not be allocated for internal structures.
EXAMPLE
#include <libconfig.h> #include <stdlib.h> #include <stdio.h> int main(int argc, char **argv) { int lc_p_ret, lc_rv_ret; char *filename = NULL; lc_rv_ret = lc_register_var("File", LC_VAR_STRING, &filename, 'f'); if (lc_rv_ret != 0) { fprintf(stderr, "Error registering variable: %i.\n", lc_geterrno()); return(EXIT_FAILURE); } lc_p_ret = lc_process(argc, argv, "example", LC_CONF_APACHE, NULL); lc_cleanup(); if (lc_p_ret != 0) { fprintf(stderr, "Error processing configuration: \ %s\n", lc_geterrstr()); return(EXIT_FAILURE); } if (filename != NULL) { printf("File specified was: %s\n", filename); } else { printf("No filename specified.\n"); } return(EXIT_SUCCESS); }
SEE ALSO
libconfig(3), lc_register_var(3), lc_register_callback(3), lc_geterrstr(3), lc_seterrstr(3), lc_handle_type(3), lc_process(3), lc_process_file(3), lc_cleanup(3)